<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Adminis
  Date: 2025/3/19
  Time: 11:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>权限管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/admin/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/admin/js/jquery-2.1.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/admin/js/bootstrap.min.js"></script>
    <style>
        .cus-container {
            width: 100%;
            max-width: 1368px;
            margin: 0 auto;
        }

        .table-container {
            margin-top: 20px;
        }

        .table-container th {
            background-color: forestgreen;
            color: white;
            font-weight: bold;
            padding: 12px;
        }

        .table-container td {
            vertical-align: middle;
            padding: 10px;
        }

        .table-container #child td {
            padding-left: 60px;
        }

        .btn-container {
            margin-bottom: 10px;
        }

        .btn-container a {
            margin-right: 5px;
        }

        /* 自定义表格边框样式 */
        .table-container table {
            border: 1px solid #dee2e6; /* 表格边框颜色 */
            width: 100%; /* 确保表格占据整个容器宽度 */
            border-collapse: collapse; /* 合并边框 */
        }

        .table-container table th,
        .table-container table td {
            border: 1px solid #dee2e6; /* 单元格边框颜色 */
        }

        /* 悬停效果 */
        .table-container table tbody tr:hover {
            background-color: #f8f9fa;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .cus-container {
                padding: 10px;
            }

            .table-container th,
            .table-container td {
                padding: 8px;
            }

            .table-container #child td {
                padding-left: 30px;
            }
        }

        /* 自定义a标签样式 */
        .table-container a.btn {
            text-decoration: none; /* 去掉下划线 */
            padding: 5px 10px; /* 增加内边距 */
            border-radius: 4px; /* 圆角 */
            transition: background-color 0.3s, color 0.3s; /* 过渡效果 */
        }

        .table-container a.btn.btn-primary {
            background-color: #007bff;
            color: white;
        }

        .table-container a.btn.btn-primary:hover {
            background-color: #0056b3;
        }

        .table-container a.btn.btn-danger {
            background-color: #dc3545;
            color: white;
        }

        .table-container a.btn.btn-danger:hover {
            background-color: #c82333;
        }

        .table-container a.btn.btn-sm {
            font-size: 0.875rem; /* 减小字体大小 */
        }

        /* 自定义“添加权限”按钮样式 */
        .btn-container a.btn.btn-primary {
            background-color: #28a745; /* 更改为绿色 */
            color: white;
            font-weight: bold; /* 加粗字体 */
        }

        .btn-container a.btn.btn-primary:hover {
            background-color: #218838; /* 更深的绿色 */
        }

        .btn-container a.btn.btn-primary:active {
            background-color: #1e7e34; /* 按下时的颜色 */
        }
    </style>
</head>
<body>

<div class="container cus-container">
    <h3 class="text-center">权限信息列表</h3>

    <div class="btn-container">
        <!-- 添加、删除的按钮 -->
        <a class="btn btn-primary" href="${pageContext.request.contextPath}/acl_permission/toInsertAcl_permissionParent">添加权限</a>
    </div>

    <div class="table-container">
        <table class="table table-striped table-bordered table-hover mx-auto">
            <thead>
            <tr>
                <th>权限名称</th>
                <th>访问路径</th>
                <th>权限操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${aclPermissions}" var="acl_permission">
                <tr>
                    <td>${acl_permission.name}</td>
                    <td>${acl_permission.path}</td>
                    <td>
                        <a class="btn btn-danger btn-sm" href="${pageContext.request.contextPath}/acl_permission/deleteAcl_permission?perm_id=${acl_permission.perm_id}">删除</a>
                        <a class="btn btn-primary btn-sm" href="${pageContext.request.contextPath}/acl_permission/toUpdateAcl_permission?perm_id=${acl_permission.perm_id}">修改</a>
                        <a class="btn btn-primary btn-sm" href="${pageContext.request.contextPath}/acl_permission/toInsertAcl_permissionParent?perm_id=${acl_permission.perm_id}">增加子权限</a>
                    </td>
                </tr>
                <c:forEach items="${acl_permission.children}" var="child">
                    <tr id="child">
                        <td>${child.name}</td>
                        <td>${child.path}</td>
                        <td>
                            <a class="btn btn-danger btn-sm" href="${pageContext.request.contextPath}/acl_permission/deleteAcl_permission?perm_id=${child.perm_id}">删除</a>
                            <a class="btn btn-primary btn-sm" href="${pageContext.request.contextPath}/acl_permission/toUpdateAcl_permission?perm_id=${child.perm_id}">修改</a>
                        </td>
                    </tr>
                </c:forEach>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>

</body>
</html>
